<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Technoweenie::AttachmentFu::Processors::ImageScienceProcessor</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Technoweenie::AttachmentFu::Processors::ImageScienceProcessor</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor_rb.html">
                vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000014">included</a>&nbsp;&nbsp;
      <a href="#M000015">process_attachment_with_processing</a>&nbsp;&nbsp;
      <a href="#M000016">resize_image</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="ImageScienceProcessor/ClassMethods.html" class="link">Technoweenie::AttachmentFu::Processors::ImageScienceProcessor::ClassMethods</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">included</span><span class="method-args">(base)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb, line 6</span>
6:         <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>(<span class="ruby-identifier">base</span>)
7:           <span class="ruby-identifier">base</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:extend</span>, <span class="ruby-constant">ClassMethods</span>
8:           <span class="ruby-identifier">base</span>.<span class="ruby-identifier">alias_method_chain</span> <span class="ruby-identifier">:process_attachment</span>, <span class="ruby-identifier">:processing</span>
9:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">process_attachment_with_processing</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb, line 19</span>
19:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_attachment_with_processing</span>
20:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">process_attachment_without_processing</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">image?</span>
21:             <span class="ruby-identifier">with_image</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">img</span><span class="ruby-operator">|</span>
22:               <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">width</span>  = <span class="ruby-identifier">img</span>.<span class="ruby-identifier">width</span>  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:width</span>)
23:               <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">height</span> = <span class="ruby-identifier">img</span>.<span class="ruby-identifier">height</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:height</span>)
24:               <span class="ruby-identifier">resize_image_or_thumbnail!</span> <span class="ruby-identifier">img</span>
25:             <span class="ruby-keyword kw">end</span>
26:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <a href="#M000016" class="method-signature">
          <span class="method-name">resize_image</span><span class="method-args">(img, size)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Performs the actual resizing operation for a thumbnail
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000016-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb, line 29</span>
29:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resize_image</span>(<span class="ruby-identifier">img</span>, <span class="ruby-identifier">size</span>)
30:             <span class="ruby-comment cmt"># create a dummy temp file to write to</span>
31:             <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub!</span> <span class="ruby-regexp re">/gif$/</span>, <span class="ruby-value str">'png'</span>
32:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">temp_path</span> = <span class="ruby-identifier">write_to_temp_file</span>(<span class="ruby-identifier">filename</span>)
33:             <span class="ruby-identifier">grab_dimensions</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">img</span><span class="ruby-operator">|</span>
34:               <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">width</span>  = <span class="ruby-identifier">img</span>.<span class="ruby-identifier">width</span>  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:width</span>)
35:               <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">height</span> = <span class="ruby-identifier">img</span>.<span class="ruby-identifier">height</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:height</span>)
36:               <span class="ruby-identifier">img</span>.<span class="ruby-identifier">save</span> <span class="ruby-identifier">temp_path</span>
37:               <span class="ruby-identifier">callback_with_args</span> <span class="ruby-identifier">:after_resize</span>, <span class="ruby-identifier">img</span>
38:             <span class="ruby-keyword kw">end</span>
39: 
40:             <span class="ruby-identifier">size</span> = <span class="ruby-identifier">size</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
41:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">size</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Fixnum</span>))
42:               <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Fixnum</span>)
43:                 <span class="ruby-identifier">img</span>.<span class="ruby-identifier">thumbnail</span>(<span class="ruby-identifier">size</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">grab_dimensions</span>)
44:               <span class="ruby-keyword kw">else</span>
45:                 <span class="ruby-identifier">img</span>.<span class="ruby-identifier">resize</span>(<span class="ruby-identifier">size</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">size</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">&amp;</span><span class="ruby-identifier">grab_dimensions</span>)
46:               <span class="ruby-keyword kw">end</span>
47:             <span class="ruby-keyword kw">else</span>
48:               <span class="ruby-identifier">new_size</span> = [<span class="ruby-identifier">img</span>.<span class="ruby-identifier">width</span>, <span class="ruby-identifier">img</span>.<span class="ruby-identifier">height</span>] <span class="ruby-operator">/</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>
49:               <span class="ruby-identifier">img</span>.<span class="ruby-identifier">resize</span>(<span class="ruby-identifier">new_size</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">new_size</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">&amp;</span><span class="ruby-identifier">grab_dimensions</span>)
50:             <span class="ruby-keyword kw">end</span>
51:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>